/*
 * CPU.c
 *
 *  Created on: May 22, 2013
 *      Author: fahad
 */


/*
 * Main.c
 *
 *  Created on: May 19, 2013
 *      Author: fahad
 */
/**
 * The CPU object is the main loop that "runs" the running process.
 *  This is basically a loop that counts a number of steps (machine instructions)
 *   modulo some number between 1,000 and 10,000 (do experiments!).
 *   That is the counter loops back to zero at some point.
 *   Each process should have a different number within the range, randomly generated
 *   at startup,  that it passes to the CPU to indicate the count at which a system call
 *    is made. Different processes should have different points in their count where the
 *     calls are made. The count represents the execution address so that if an interrupt
 *      occurs, that value is stored in the PCB while the interrupt is serviced.
The CPU doesn't actually do much during an interrupt service. It has to save the state of
the currently running process (don't worry about simulating stacks in this version) and
start running an interrupt service routine. The results of the routine will depend on what
kind of interrupt is being serviced. If it is a timer interrupt then the CPU needs to
simulate the timer interrupt, which, in turn, calls the scheduler and that does a context
switch. There is no single right way to manipulate the data here, but the simulation
should clearly demonstrate that a timer interrupt (using a time slice preemption model)
causes a new process to get to run. Don't forget to instantiate an idle task
(do nothing loop) and make sure it is always available in the ready queue,
The CPU can be simulated as a busy loop that increments the current process's PC and
then checks to see if the current count causes any requests to occur. If so, the CPU has to
save the state and run the appropriate request system call. In actuallity the system calls
can just be simple helper functions or even part of the CPU in a switch statement.
That is left to you to decide. However you do it, the trap service routine should
manipulate the appropriate data structures (PCBs, blocked queues, etc.) and then call
the scheduler as with the interrupt processing.
 *
 */
#include <stdio.h>
#include <stdlib.h>
#define Thousand 1000;
// different number within the range, randomly generated at startup
int MAX = 10000;
int main()
{
	int process;

	int index;

	// that value is stored in the PCB
	int PCB;
	//modulo some number between 1,000 and 10,000

	for(index = 0; index < 20; index++)
	{
		int number;
		number = rand();
		int result =  number %(MAX -1) +1;

		printf("%d\n", result);

		for(process = result; process <= 10000; process++)
		{
		printf("%d\n", process);
		}
	}
}
